package com.niit.service.impl;

import java.util.List;

import com.niit.bean.Classify;
import com.niit.dao.ClassifyDao;
import com.niit.dao.impl.ClassifyDaoImpl;
import com.niit.service.ClassifyService;
import com.niit.utils.Page;

public class ClassifyServiceImpl implements ClassifyService {
	
	private ClassifyDao dao = new ClassifyDaoImpl();
	@Override
	public int add(Classify t) {
		return dao.add(t);
	}

	@Override
	public int delete(Classify t) {
		return dao.delete(t);
	}

	@Override
	public int update(Classify t) {
		return dao.update(t);
	}

	@Override
	public Page<Classify> getPage(String pagenum, String url) {
		int total = dao.findTotal();//查出总记录数
		Page<Classify> page = null;
		if(pagenum == null){
			page = new Page<Classify>(total,1);
		}else{
			page = new Page<Classify>(total, Integer.parseInt(pagenum));
		}
		List<Classify> list = dao.findAll(page.getStartIndex(), page.getEndIndex());
		page.setList(list);
		page.setUrl(url);
		return page;
	}

	@Override
	public List<Classify> findAll() {
		return dao.findAll(0, dao.findTotal());
	}

}
